<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 门铎
  Date: 2016/6/24
  Time: 9:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>智能海洋机器人研究中心-后台</title>
    <!-- BOOTSTRAP STYLES-->
    <link href="${pageContext.request.contextPath}/css/bootstrap.css" rel="stylesheet" />
    <!-- FONTAWESOME STYLES-->
    <link href="${pageContext.request.contextPath}/css/font-awesome.css" rel="stylesheet" />
    <!-- PAGE LEVEL STYLES -->
    <link href="${pageContext.request.contextPath}/css/bootstrap-fileupload.min.css" rel="stylesheet" />
    <!--CUSTOM BASIC STYLES-->
    <link href="${pageContext.request.contextPath}/css/basic.css" rel="stylesheet" />
    <!--CUSTOM MAIN STYLES-->
    <link href="${pageContext.request.contextPath}/css/custom.css" rel="stylesheet" />
    <link rel="shortcut icon" href="${pageContext.request.contextPath}/img/ico.ico" />
</head>
<style>
    .title-a{
        font-size: 14px;
        color: #00b7ee;
        text-decoration: none;
    }
</style>
<body>
<div id="wrapper">
    <jsp:include page="../manage/nav-top.jsp"/>
    <jsp:include page="../manage/nav.jsp"/>
    <!-- /. NAV SIDE  -->
    <div id="page-wrapper">
        <div id="page-inner">
            <div class="row">
                <div class="col-md-12">
                    <ol class="breadcrumb">
                        <li><a href="#">首页</a></li>
                        <li><a href="#">科研团队</a></li>
                        <li class="active">研究方向</li>
                    </ol>
                    <hr />
                    <ul class="nav nav-pills">
                        <li>
                            <a href="${pageContext.request.contextPath}/cimv/option/direction/list">
                                <i class="glyphicon glyphicon-user"></i>标题列表
                            </a>
                        </li>
                        <li >
                            <a href="${pageContext.request.contextPath}/cimv/option/direction/new">
                                <i class="glyphicon glyphicon-user"></i>新增标题
                            </a>
                        </li>
                        <li>
                            <a href="${pageContext.request.contextPath}/cimv/option/direction/contentList">
                                <i class="glyphicon glyphicon-plus"></i>内容列表
                            </a>
                        </li>
                        <li class="active">
                            <a href="${pageContext.request.contextPath}/cimv/option/direction/contentNew">
                                <i class="glyphicon glyphicon-plus"></i>新增内容
                            </a>
                        </li>
                    </ul>
                    <hr />
                </div>
            </div>
            <!-- /. ROW  -->
            <div class="row">
                <div class="col-md-12">
                    <div class="form-group">
                        <label>排序序号</label>
                        <input class="form-control"  type="text" id="sid" value="${direction.sid}">
                        <p class="help-block"></p>
                    </div>
                    <div class="form-group">
                        <label>所属分类</label>
                        <select class="form-control" id="oid">
                            <c:forEach var="op" items="${options}" >
                                <c:choose>
                                    <c:when test="${op.id == direction.oid}">
                                        <option value="${op.id}" selected="selected">${op.title}</option>
                                    </c:when>
                                    <c:otherwise>
                                        <option value="${op.id}">${op.title}</option>
                                    </c:otherwise>
                                </c:choose>

                            </c:forEach>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>内容</label>
                        <input class="form-control"  type="text" id="content" value="${direction.content}">
                        <p class="help-block"></p>
                    </div>
                    <button class="btn btn-primary " data-toggle="modal"
                            data-target="#myModal">
                        提交
                    </button>
                    <!-- 模态框（Modal） -->
                    <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
                         aria-labelledby="myModalLabel" aria-hidden="true">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close"
                                            data-dismiss="modal" aria-hidden="true">
                                        &times;
                                    </button>
                                    <h4 class="modal-title" id="myModalLabel">
                                        提示
                                    </h4>
                                </div>
                                <div class="modal-body">
                                    确定要更新么？
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default"
                                            data-dismiss="modal">关闭
                                    </button>
                                    <button  id="insert"  type="button" class="btn btn-primary" data-dismiss="modal">
                                        确定
                                    </button>
                                </div>
                            </div><!-- /.modal-content -->
                        </div><!-- /.modal -->
                    </div>
                    <div  id="myModal2" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
                        <div class="modal-dialog modal-sm">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                    <h4 class="modal-title" id="exampleModalLabel">提示</h4>
                                </div>

                                <div class="modal-body">
                                    <div id="myModel2Msg" class="alert alert-success">
                                        发布成功！
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /. ROW  -->
        </div>
    </div>
    <!-- /. PAGE WRAPPER  -->
</div>
<!-- /. WRAPPER  -->

<jsp:include page="../manage/footer.jsp" />
<!-- SCRIPTS -AT THE BOTOM TO REDUCE THE LOAD TIME-->
<!-- JQUERY SCRIPTS -->
<script src="${pageContext.request.contextPath}/js/jquery-1.10.2.js"></script>
<!-- BOOTSTRAP SCRIPTS -->
<script src="${pageContext.request.contextPath}/js/bootstrap.js"></script>
<!-- PAGE LEVEL SCRIPTS -->
<script src="${pageContext.request.contextPath}/js/bootstrap-fileupload.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.ui.widget.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.iframe-transport.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.fileupload.js"></script>

<!-- METISMENU SCRIPTS -->
<script src="${pageContext.request.contextPath}/js/jquery.metisMenu.js"></script>
<!-- CUSTOM SCRIPTS -->
<script src="${pageContext.request.contextPath}/js/custom.js"></script>

<!-- 实例化编辑器 -->
<script type="text/javascript">

    $(function(){
        $('#insert').click(function () {
            var  content = $("#content").val();
            var  sid = $("#sid").val();
            var  oid = $("#oid").val();
            $.ajax({
                url: '${pageContext.request.contextPath}/cimv/option/direction/contentUpdateD',
                type: 'POST',
                dataType: 'json',
                data: {
                    "id":"${direction.id}",
                    "sid": sid,
                    "oid":oid,
                    "content": content
                }
            }).done(function(data) {
                        $('#myModel2Msg').html(""+data.msg);
                        $('#myModal2').modal('show');
                        setTimeout(function () {
                            $('#myModal2').modal('hide');
                        },1000*2);
                    })
                    .fail(function(data) {
                        console.log(data);
                        console.log("error");
                    })
                    .always(function() {
                        console.log("complete");
                    });
        });


    });
</script>


</body>

</html>
